package top.honlnk.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Base64;

@Slf4j
public class ImageFileToBase64Util {
    public String ProcessorData(MultipartFile file) {

        // 读取文件内容到字节数组
        byte[] fileBytes;
        try {
            fileBytes = file.getBytes();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        // 将字节数组转换为Base64字符串
        return Base64.getEncoder().encodeToString(fileBytes);
    }

}
